package com.example.rwq_test.niuke.stack;

import java.util.Stack;

/**
 * TODO note
 *
 * @author renweiqiang
 * @version 1.0.0
 * @createTime 2023/11/27
 */
public class TwoStackArray {
    private static Stack<Integer> in = new Stack<>();
    private static Stack<Integer> out = new Stack<>();

    public static void push(int val) {
        in.push(val);
    }

    public static int pop() {
        if (out.isEmpty()) {
           while (!in.isEmpty()) {
               out.push(in.pop());
           }
        }
        return out.pop();
    }

    public static void main(String[] args) {
        push(1);
        push(2);
        System.out.println(pop());
        push(3);
        System.out.println(pop());
        System.out.println(pop());
    }

}
